package com.hunan.api.catv.action.account;

import com.hunan.api.catv.action.BaseAction;
import com.hunan.api.catv.annotation.MemberAuth;
import com.hunan.api.catv.common.Api;
import com.hunan.api.catv.entity.Result;
import com.hunan.api.catv.entity.po.MemberAssets;
import com.hunan.api.catv.service.biz.account.AccountBiz;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import javax.validation.constraints.NotNull;

/**
 * @Author: wangchao
 * @Date: 2020/10/23 10:44
 */
@RestController
@RequestMapping(Api.account)
@Validated
public class AccountAction extends BaseAction {

    @Autowired
    AccountBiz accountBiz;


    /**
     * 查询用户资产信息
     */
    @GetMapping("/getMemberAssentsInfo/{memberId}")
    public Result getMemberAssentsInfo(@NotNull @PathVariable("memberId") Integer memberId) {
        return buildOK(accountBiz.getMemberAssentsInfo(memberId), "");
    }

    /**
     * 查询用户资产信息
     */
    @MemberAuth
    @GetMapping("/getMemberAssentsInfo")
    public Result getMemberAssentsInfo(HttpServletRequest request) {
        return buildOK(accountBiz.getMemberAssentsInfo(getMemberId(request)), "");
    }


    /**
     * 保存用户资产信息
     */
    @PostMapping("/saveMemberAssentsInfo")
    public Result saveMemberAssentsInfo(@RequestBody MemberAssets memberAssets) {
        return buildOK(accountBiz.saveMemberAssentsInfo(memberAssets), "");
    }

    /**
     * 修改用户资产信息
     *
     * @param memberAssets
     * @return
     */
    @PutMapping("/updateMemberAssentsInfo")
    public Result updateMemberAssentsInfo(@RequestBody MemberAssets memberAssets) {
        return buildOK(accountBiz.updateMemberAssentsInfo(memberAssets), "");
    }
}
